package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	student := Student{
		Id:   1,
		Name: "haha",
	}
	jsonByte, err := toJsonByte(student)
	if err != nil {
		fmt.Println("jsonBytes", jsonByte)
	}
	var result Student
	parseJson(jsonByte, &result)
	fmt.Println("res:", result)
}

func parseJson(byteJson []byte, target *Student) {
	json.Unmarshal(byteJson, target)
}
func toJsonByte(student Student) ([]byte, error) {
	return json.Marshal(student)
}

type Student struct {
	Id   int
	Name string
}
